<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
    <head>
        <title>Tigua Reference</title>
        <meta http-equiv="content-language" content="en">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="author" content="David M. Lopez">
        <meta name="description" content="Canvas JavaScript Library">
        <meta name="keywords" content="JavaScript Library, Tigua, Canvas">
        <meta name="viewport" content="width=450; user-scalable=no">
        <link rel="stylesheet" type="text/css" media="screen,print" href="../util/log4javascript/main.css" title="Default" /> 
        <script src="../util/log4javascript/log4javascript.js" type="text/javascript" charset="utf-8"></script>
        <script src="../tigua.js" type="text/javascript" charset="utf-8"></script>
        
        <script>
			    
        function startup() {
          var log = log4javascript.getDefaultLogger("main");
			    //var appender = new log4javascript.BrowserConsoleAppender();
			    //appender.setLayout(new log4javascript.PatternLayout(log4javascript.ABSOLUTETIME_DATEFORMAT));
			    //log.addAppender(appender);
			    var tests=0;
			    var success=0;
			    
			    //attach to existing canvas in page
          var c = new tigua.canvas('cnvs');
          
			    log.debug("Component tests");
			    
			    log.debug("constructor with empty argument");
			    
			    var comp = new tigua.component();
			    comp.setWidth(300);
			    comp.setHeight(300);
			    comp.setId('c1');
			    
          tests++;
          comp.getWidth() == 300  ? success++ : log.error("Error with getWidth, should be 300: " +comp.getWidth());
          tests++;
          comp.getHeight() == 300 ? success++ : log.error("Error with getHeight, should be 300: "+comp.getHeight());
          tests++;
          comp.getId() === "c1"  ? success++ : log.error("Error with getId, should be c1: "+comp.getId());
          
          comp.setDimension(275,275);
          tests++;
          comp.getWidth()  == 275 ? success++ : log.error("Error with getWidth, should be 275: " +comp.getWidth());
          tests++;
          comp.getHeight() == 275 ? success++ : log.error("Error with getHeight, should be 275: "+comp.getHeight());
                    
          comp.setX(300);
          comp.setY(1);
          
          tests++;
          comp.getX() == 300 ? success++ : log.error("Error with getX, should be 300: "+comp.getX());
          tests++;
          comp.getY() == 1   ? success++ : log.error("Error with getY, should be 1: "  +comp.getY());
          
          comp.setXY(400,10);
          tests++;
          comp.getX() == 400 ? success++ : log.error("Error with getX, should be 400: " +comp.getX());
          tests++;
          comp.getY() == 10  ? success++ : log.error("Error with getY, should be 10: "  +comp.getY());

 			    log.debug("constructor with object arg");
			    
			    comp = new tigua.component({id:'c2',x:1,y:2,width:100,height:200});
			    
          tests++;
          comp.getWidth() == 100  ? success++ : log.error("Error with getWidth, should be 100: "+comp.getWidth());
          tests++;
          comp.getHeight() == 200 ? success++ : log.error("Error with getHeight, should be 200: "+comp.getHeight());
          tests++;
          comp.getId() === "c2"  ? success++ : log.error("Error with getId, should be c2: "+comp.getId());
          tests++;
          comp.getX() == 1 ? success++ : log.error("Error with getX, should be 1: "+comp.getX());
          tests++;
          comp.getY() == 2 ? success++ : log.error("Error with getY, should be 2: "+comp.getY());

          log.debug(tests+" cases performed");          
          log.debug(success+" cases passed");
        }
        </script>
    </head>
    <body onload="startup();">
      <canvas id="cnvs" width="300" height="300"></canvas>
    </body>
</html>
